import 'dart:async';

Function debounce<T>(
    void Function(T) func, {
      Duration delay = const Duration(milliseconds: 500),
    }) {
  Timer? timer;
  return (T arg) {
    timer?.cancel();
    timer = Timer(delay, () => func(arg));
  };
}
